//
//  TabBarViewController.m
//  EconomyDemo
//
//  Created by qianfeng01 on 15-7-4.
//  Copyright (c) 2015年 xiangmu. All rights reserved.
//

#import "TabBarViewController.h"
#import "WMPageController.h"
@interface TabBarViewController ()

@end

@implementation TabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self creatViewController];
}
-(void)creatViewController{
    NSArray *titles=@[@"财经",@"图库",@"视频",@"用户中心"];
    NSArray *tabbarPics=@[@"money",@"atlas",@"video",@"userimage"];
   
    NSMutableArray *Name=[NSMutableArray arrayWithArray:@[@"FinanceViewController",@"MomentViewController",@"VideoViewController",@"UsersViewController"]];
    NSArray *RollTitles=@[@"头条",@"原创",@"政经",@"金融",@"产业",@"风尚"];
    NSArray *RollArr=@[@"HeadlinesViewController",@"OriginalViewController",@"PoliticalViewController",@"FinancialViewController",@"IndustryViewController",@"PrevailingViewController"];
    NSMutableArray *rlArr=[[NSMutableArray alloc] init];
     NSMutableArray *allArr=[[NSMutableArray alloc] init];
    for (int i=0; i<RollArr.count; i++) {
        Class cls=NSClassFromString(RollArr[i]);
        UIViewController *vc=[[cls alloc] init];
        [rlArr addObject:vc];
    }
    WMPageController *pc=[[WMPageController alloc] initWithViewControllers:rlArr andTheirTitles:RollTitles];
    UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:pc];
    pc.title=titles[0];
    pc.tabBarItem.image=[UIImage imageNamed:tabbarPics[0]];
    [nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"header_bg.png"] forBarMetrics:UIBarMetricsDefault];
    [allArr addObject:nav];
    for (NSInteger i=1; i<Name.count; i++) {
        Class cls=NSClassFromString(Name[i]);
        UIViewController *MoneyView=[[cls alloc] init];
        UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:MoneyView];
        nav.tabBarItem.title=titles[i];
        nav.tabBarItem.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",tabbarPics[i]]];
        
        MoneyView.title=titles[i];
        
        [nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"header_bg.png"] forBarMetrics:UIBarMetricsDefault];
        [allArr addObject:nav];
        
    }
    self.viewControllers=allArr;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
